# Maintainer: Ronald van Haren <ronald.archlinux.org>
# Maintainer: Giancarlo Razzolini <grazzolini@archlinux.org>
# Contributor: Tom Killian <tom.archlinux.org>
# Contributor: Judd Vinet <jvinet.zeroflux.org>

pkgname=dhcpcd
pkgver=9.4.0
pkgrel=1
pkgdesc="RFC2131 compliant DHCP client daemon"
url="https://roy.marples.name/projects/dhcpcd/"
arch=('x86_64')
license=('BSD')
depends=('glibc' 'sh' 'udev' 'systemd-libs')
optdepends=('openresolv: resolvconf support')
provides=('dhcp-client')
backup=('etc/dhcpcd.conf')
install='dhcpcd.install'
options=('emptydirs')  # We Need the Empty /var/lib/dhcpcd Directory
source=("https://roy.marples.name/downloads/$pkgname/$pkgname-$pkgver.tar.xz"
        dhcpcd.install
        dhcpcd_.service
        dhcpcd.service
        dhcpcd.sysusers
        dhcpcd.tmpfiles)
validpgpkeys=('A785ED2755955D9E93EA59F6597F97EA9AD45549')  # Roy Marples (NetBSD) <roy@NetBSD.org>
sha256sums=('41a69297f380bf15ee8f94f73154f8c2bca7157a087c0d5aca8de000ba1d4513'
            'd40d51367fcf7e9596e42cd2bab59404633bedbab4d0a3183e7246b4677937b7'
            '37acd53a589711f5e1db2fcaebb4ccf1c90dc4bcd309626bde25beb7b630a545'
            '20bccbf8a05b1bc2be365c8b4b526c38c752f48229ba53c3be113ac5b634f210'
            '06788ad9f5f7ccb5d2a2da6f0322ff5771f8de82cfbe8b9ad954f2c38265e21b'
            '55d57b958f6b7e4d4a538ee88b0fcc1a522050c2d38efb5d680139f618234b35')
# prepare () {
#   cd ${pkgname}-${pkgver}
# }

build() {
  cd ${pkgname}-${pkgver}

  # configure variables
  ./configure \
      --prefix=/usr \
      --sysconfdir=/etc \
      --sbindir=/usr/bin \
      --libexecdir=/usr/lib/dhcpcd \
      --dbdir=/var/lib/dhcpcd \
      --runstatedir=/run \
      --privsepuser=dhcpcd

  # Build
  make
}


check() {
  cd ${pkgname}-${pkgver}

  make test
}


package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install

  # Install License
  install -Dm644 "${srcdir}/${pkgname}-${pkgver}/LICENSE" \
	  "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  # Set Options in /etc/dhcpcd.conf
  echo noipv4ll >> "${pkgdir}/etc/dhcpcd.conf" # Disable ip4vall

  # install systemd files
  install -Dm644 "${srcdir}/dhcpcd_.service" "${pkgdir}/usr/lib/systemd/system/dhcpcd@.service"
  install -Dm644 "${srcdir}/dhcpcd.service" "${pkgdir}/usr/lib/systemd/system/dhcpcd.service" # FS#31543
  install -Dm644 "${srcdir}/dhcpcd.sysusers" "${pkgdir}/usr/lib/sysusers.d/dhcpcd.conf"
  install -Dm644 "${srcdir}/dhcpcd.tmpfiles" "${pkgdir}/usr/lib/tmpfiles.d/dhcpcd.conf"
}
